/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Database;

import callcenter.Medium;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Vector;

/**
 *
 * @author DELL INSPIRON N5010
 */
public class DetailSalesBill
{
    private int  ProductId;
    private int BillId;
    private double Price;
    private int Quantity;
    private int DiscountRate;
    private String Description;

    /**
     * @return the ProduceId
     */
    public int getProductId() {
        return ProductId;
    }

    /**
     * @param ProduceId the ProduceId to set
     */
    public void setProductId(int ProduceId) {
        this.ProductId = ProduceId;
    }

    /**
     * @return the BillId
     */
    public int getBillId() {
        return BillId;
    }

    /**
     * @param BillId the BillId to set
     */
    public void setBillId(int BillId) {
        this.BillId = BillId;
    }

    /**
     * @return the Price
     */
    public double getPrice() {
        return Price;
    }

    /**
     * @param Price the Price to set
     */
    public void setPrice(double Price) {
        this.Price = Price;
    }

    /**
     * @return the Quantity
     */
    public int getQuantity() {
        return Quantity;
    }

    /**
     * @param Quantily the Quantity to set
     */
    public void setQuantity(int Quantity) {
        this.Quantity = Quantity;
    }

    /**
     * @return the DiscountRate
     */
    public int getDiscountRate() {
        return DiscountRate;
    }

    /**
     * @param DiscountRate the DiscountRate to set
     */
    public void setDiscountRate(int DiscountRate) {
        this.DiscountRate = DiscountRate;
    }

    /**
     * @return the Description
     */
    public String getDescription() {
        return Description;
    }

    /**
     * @param Description the Description to set
     */
    public void setDescription(String Description) {
        this.Description = Description;
    }
    public Vector<Vector<Object>> lisdetailsalesbill()
    {
        Vector<Vector<Object>> listdtsb=new Vector<Vector<Object>>();
        try
        {
            Connection con=ConecttoDatabase.getConnection();
            String query="select t3.ProductName,t2.Price,t2.Quantity,t2.DiscountRate,t2.Description from SalesBill t1, DetailSalesBill t2, Product t3 where t1.BillId=t2.BillId and t2.ProductId=t3.ProductId and t2.BillId=?";
            //Statement st=con.createStatement();
            PreparedStatement ps=con.prepareCall(query);
            ps.setInt(1, Medium.jifs.getselectedsalesbillid());
            ResultSet rs=ps.executeQuery();
            while(rs.next())
            {
                Vector<Object> rows=new Vector<Object>();
                //rows.add(rs.getInt("BillId"));
                rows.add(rs.getString("ProductName"));
                rows.add(rs.getDouble("Price"));
                rows.add(rs.getInt("Quantity"));
                rows.add(rs.getInt("DiscountRate"));
                rows.add(rs.getString("Description"));
                
                listdtsb.add(rows);
            }
        }
        catch(Exception ex)
        {
            System.out.println(ex);
            listdtsb=null;
        }
        return listdtsb;
    }
}
